package com.xbts.screen.controller.workshop;

import com.xbts.common.core.constant.CacheConstants;
import com.xbts.common.core.constant.Constants;
import com.xbts.common.core.utils.StringUtils;
import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.ILineDetectionService;
import com.xbts.screen.service.IWeVirtualDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 线路检测车间Controller
 */
@Api(tags = "线路检测车间")
@RestController
@RequestMapping("/lineDetection")
public class LineDetectionController extends BaseController {


    @Autowired
    private ILineDetectionService lineDetectionService;

    /**
     * 实时达成率
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:lineDetection:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = lineDetectionService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:lineDetection:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = lineDetectionService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:lineDetection:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = lineDetectionService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:lineDetection:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = lineDetectionService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:lineDetection:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = lineDetectionService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:lineDetection:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = lineDetectionService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:lineDetection:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = lineDetectionService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:lineDetection:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = lineDetectionService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 合格率趋势
     */
    @ApiOperation("合格率趋势")
    @RequiresPermissions("workshop:lineDetection:passRateTrend")
    @GetMapping("/passRateTrend")
    public AjaxResult passRateTrend(){
        BaseHistogramResult result = lineDetectionService.passRateTrend();
        return success(result);
    }
    /**
     * 报废率趋势
     */
    @ApiOperation("报废率趋势")
    @RequiresPermissions("workshop:lineDetection:scrapRateTrend")
    @GetMapping("/scrapRateTrend")
    public AjaxResult scrapRateTrend(){
        BaseHistogramResult result = lineDetectionService.scrapRateTrend();
        return success(result);
    }
    /**
     * PCS_合格率
     */
    @ApiOperation("PCS_合格率")
    @RequiresPermissions("workshop:lineDetection:passRate")
    @GetMapping("/PCS/passRate")
    public AjaxResult PCS_passRate(){
        PassRateVO vo = lineDetectionService.PCS_passRate();
        return success(vo);
    }
    /**
     * PCS_不良统计
     */
    @ApiOperation("PCS_不良统计")
    @RequiresPermissions("workshop:lineDetection:badStatistics")
    @GetMapping("/PCS/badStatistics")
    public AjaxResult PCS_badStatistics(){
        List<BasePieChartResult> resultList = lineDetectionService.PCS_badStatistics();
        return success(resultList);
    }
    /**
     * PCS_报废合格率
     */
    @ApiOperation("PCS_报废合格率")
    @RequiresPermissions("workshop:lineDetection:scrapPassRate")
    @GetMapping("/PCS/scrapPassRate")
    public AjaxResult PCS_scrapPassRate(){
        ScrapRateVO vo = lineDetectionService.PCS_scrapPassRate();
        return success(vo);
    }
    /**
     * PCS_报废统计
     */
    @ApiOperation("PCS_报废统计")
    @RequiresPermissions("workshop:lineDetection:scrapStatistics")
    @GetMapping("/PCS/scrapStatistics")
    public AjaxResult PCS_scrapStatistics(){
        List<BasePieChartResult> resultList = lineDetectionService.PCS_scrapStatistics();
        return success(resultList);
    }
    /**
     * 料号批次合格率记录
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:lineDetection:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = lineDetectionService.passRateRecord();
        return success(resultList);
    }
}
